package codetop.greedy;

import java.util.Arrays;
import java.util.Comparator;

public class Code452 {
    public int findMinArrowShots(int[][] points) {
        Arrays.sort(points, new Comparator<int[]>() {
            @Override
            public int compare(int[] o1, int[] o2) {
                return Integer.compare(o1[1],o2[1]);
            }
        });
        int end=points[0][1];
        int ans=1;
        for (int i = 1; i <points.length ; i++) {
            if (points[i][0]>end){
                end=points[i][1];
                ans++;
            }
        }
        return ans;
    }
}
